package com.agileboot.admin.controller.medicine;

import com.agileboot.common.core.dto.ResponseDTO;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.domain.banner.command.HomeBannerCommand;
import com.agileboot.domain.news.command.NewsInfoCommand;
import com.agileboot.domain.news.db.NewsInfo;
import com.agileboot.domain.news.db.NewsInfoService;
import com.agileboot.domain.news.query.NewsInfoQuery;
import com.agileboot.domain.news.vo.NewsInfoVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 新闻资讯表(NewsInfo)表控制层
 *
 * @author makejava
 * @since 2023-12-29 18:00:21
 */
@RestController
@RequestMapping("/newsInfo")
public class NewsInfoController {
    /**
     * 服务对象
     */
    @Resource
    private NewsInfoService newsInfoService;

    @PostMapping("/save")
    public ResponseDTO saveNewsInfo(@RequestBody NewsInfoCommand newsInfoCommand) {
        newsInfoService.saveNewsInfo(newsInfoCommand);
        return ResponseDTO.ok();
    }

    @DeleteMapping("/{ids}")
    public ResponseDTO deleteNewsInfo(@PathVariable List<Long> ids) {
        newsInfoService.deleteNewsInfo(ids);
        return ResponseDTO.ok();
    }

    @PostMapping("/update")
    public ResponseDTO updateNewsInfo(@RequestBody NewsInfoCommand newsInfoCommand) {
        newsInfoService.updateNewsInfo(newsInfoCommand);
        return ResponseDTO.ok();
    }

    @PostMapping("/list")
    public ResponseDTO<PageDTO<NewsInfoVO>> queryNewsInfo(NewsInfoQuery newsInfoQuery) {
        return ResponseDTO.ok(newsInfoService.queryNewsInfo(newsInfoQuery));
    }

    @PostMapping("/detail")
    public ResponseDTO<NewsInfoVO> getNewsInfoDetail(@RequestBody NewsInfoQuery newsInfoQuery) {
        return ResponseDTO.ok(newsInfoService.getNewsInfoDetail(newsInfoQuery));
    }

    /**
     * 修改新闻资讯状态
     */
    @Operation(summary = "修改新闻资讯状态")
    @PostMapping("/editStatus")
    public ResponseDTO updateNewsInfoStatus(@RequestBody NewsInfoCommand newsInfoCommand) {
        newsInfoService.editNewsInfoStatus(newsInfoCommand);
        return ResponseDTO.ok();
    }

}

